package com.devin.dao;

import com.devin.pojo.LogLogin;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface LogMapper {

    @Insert(" insert into logs values(null,#{username,jdbcType=VARCHAR}," +
            "#{visitTime,jdbcType=VARCHAR,typeHandler=com.devin.dao.typeHandler.TimeStampTypeHandler}," +
            "#{ip,jdbcType=VARCHAR}," +
            "#{method,jdbcType=VARCHAR}," +
            "#{url,jdbcType=VARCHAR}," +
            "#{duration,jdbcType=INTEGER})")
    void saveLog(LogLogin log);

    @Select(" select * from logs ")
    @Results(@Result(property = "visitTime",column = "visitTime",jdbcType = JdbcType.VARCHAR,typeHandler = com.devin.dao.typeHandler.TimeStampTypeHandler.class))
    List<LogLogin> findLogs();

    @Delete(" delete from logs where id=#{id}")
    void delLogById(Integer id);
}
